package com.example.springbootsfzy.controller.gengyifei;

import com.example.springbootsfzy.domain.ConsultantFieldAssociations;
import com.example.springbootsfzy.service.gengyifei.consultant_field_associations_service;
import com.example.springbootsfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
咨询师擅长领域关联表  接口
 */
@RestController
@RequestMapping("/consultant_field_associations")
public class consultant_field_associations_controller {
    @Autowired
    private consultant_field_associations_service service;


    //通过主键 删除咨询师擅长领域关联表
    @DeleteMapping("/delete")
    public R deletebyid(int id){
        int i = service.deleteByPrimaryKey(id);
        if (i >0){
            return R.ok(null);
        }
        return R.fail("删除失败");
    }


    //通过参数  静态插入
    @PostMapping("/add")
    public R add(ConsultantFieldAssociations record){
        int insert = service.insert(record);
        if (insert >0){
            return R.ok(null);
        }
        return R.fail("添加失败");
    }

    //通过参数  静态修改
    @PutMapping("/update")
    public R updateSelective(ConsultantFieldAssociations record){
        int i = service.updateByPrimaryKeySelective(record);
        if (i >0){
            return R.ok(null);
        }
        return R.fail("修改失败");
    }

    //通过  主键  查询

    @GetMapping("/selectbyid")
    public R selectbyid(int id){
        ConsultantFieldAssociations record = service.selectByPrimaryKey(id);
        if (record != null){
            return R.ok(record);
        }
        return R.fail("查询失败");
    }


    @GetMapping("/selectAll")
    public R selectAll(){
        List<ConsultantFieldAssociations> records = service.selectAll();
        if (records != null){
            return R.ok(records);
        }
        return R.fail("查不到!");
    }


}
